///<reference path="./DefinitelyTyped/express/express-3.0.d.ts" />
///<reference path="./DefinitelyTyped/node/node-0.8.d.ts" />
///<reference path="./DefinitelyTyped/moment/moment-1.7.d.ts" />
///<reference path="./DefinitelyTyped/socket.io/socket.io-0.9.10.d.ts" />
///<reference path="./DefinitelyTyped/knockout/knockout-2.2.d.ts" />

import express = module("express");
import net = module("http");
import io = module("socket.io");

var moment = <MomentStatic> require("moment");

var port = 80;

var app = <express.ServerApplication> express();
var server = net.createServer(app);
var manager = io.listen(server);
server.listen(port);

app.use("/", function (req, res) {
  res.sendfile(__dirname + '/index.html');
});

manager.sockets.on('connection', function (socket) {
    setInterval(function () {
        var now = moment().format("h:mm:ss");
        socket.emit('news', { message: now.toString() });
    }, 1000);
  
  socket.on('my other event', function (data) {
    console.log(data);
  });
});

var nl = document.getElementsByName("abc");
for (var i = 0; i < nl.length; ++i) {
    nl[i].textContent = "test"
}



console.log("listen on port " + port);